<?php
namespace Home\Controller;
use Think\Controller;
class UserController extends Controller {

    //显示教练列表
    public function userList(){
        $user=M('user');
        //$this->coachlist=$coach->select();
        $this->userList=$user->select();
        //var_dump($this);

        //显示编号
        $cnt=1;
        $this->assign('cnt',$cnt);

        $this->display();
    }



//重置密码
    public function userpwd($user_id)
    {
        //echo $coach_id;
        $data['user_pwd']='123456';
        $user=M('user');
        $res=$user->where("user_id=$user_id")->save($data);
        // echo $coach->getLastSql();//显示执行的sql语句
        // echo $res;
        if(false!== $res){
            $this->success('重置密码成功！');
        }else{
            $this->error('重置密码失败！');
        }

    }

    public function interfaceUser()
    {
        //$id = I('get.id');

        $user = M('user');
        $result = $user->select();
        if($result!=false)
        {
            $data = array('results' => $result);
            $this->ajaxReturn($data,'JSON');
        }
        else{
            echo "获取失败!";
        }
    }


}